#include "tetrahedronTreeItem.h"

TetrahedronTreeItem::TetrahedronTreeItem(QTreeWidgetItem *_parentItem, Tetrahedron *_t) : TreeItem(_parentItem), t(_t){
    setFlags(Qt::ItemIsSelectable);
    QString str = "Tetrahedron ";
    str.append(QString::number(t->getID()));
    setText(0, str);

    if(t->isSelected()) setSelected(true);
    else setSelected(false);
}

TetrahedronTreeItem::~TetrahedronTreeItem(){
}

void TetrahedronTreeItem::updateTetrahedron(Tetrahedron *_t){
    t = _t;
}

Tetrahedron *TetrahedronTreeItem::getTetrahedron(){
    return t;
}

void TetrahedronTreeItem::select(){
    if(t->isSelected()){
        t->select(false);
        setSelected(false);
    }else{
        t->select(true);
        setSelected(true);
    }
    emit selected(t);
}
